package com.car.controller;

import com.car.exception.CustomException;
import com.car.service.LicenseService;
import com.car.vo.JsonResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * @author 党怡承
 * @since 2021-08-09
 * @description 车牌识别控制层
 */
@Api(tags = "车牌接口")
@RestController
@RequestMapping("/license")
public class LicenseController {

  @Autowired private LicenseService licenseService;

  @ApiOperation(value = "上传车牌图片")
  @PostMapping(value = "/uploadFile")
  @ResponseStatus(HttpStatus.CREATED)
  public JsonResult licensePlate(MultipartFile multipartFile) {
    String flag = licenseService.licensePlate(multipartFile);
    if (flag == null) {
      throw new CustomException(20001,"The Current Operate Is Failed，Please Try Again");
    }
    return JsonResult.success("The Current Operate Is Successful", flag);
  }
}
